#文件类型 .ps1
# 这里填写自己的IDE的安装目录
$ide_path="C:\Program Files\Huawei\DevEco Studio"

$hvigor_path=$ide_path + '\tools\hvigor'
$filePath = $hvigor_path + "\hvigor-ohos-plugin\src\const\common-const.js"
$replaceString = 'exports\.LanguageConst=\{DEFAULT:"1\.1",ARKTS1_0:"1\.0",ARKTS1_1:"1\.1",ARKTS1_2:"1\.2",ARKTS_HYBRID:"hybrid"\};'
$searchString = 'exports.LanguageConst={DEFAULT:"ArkTS1.1",ARKTS1_0:"ArkTS1.0",ARKTS1_1:"ArkTS1.1",ARKTS1_2:"ArkTS1.2",ARKTS_HYBRID:"hybrid"};'

echo $filePath

# 读取文件内容
$content = Get-Content -Path $filePath -Raw

# 使用正则表达式进行查找和替换
$newContent = [regex]::Replace($content, $searchString, $replaceString)

# 将修改后的内容写回文件
Set-Content -Path $filePath -Value $newContent

Write-Output "替换完成"


$filePath = $hvigor_path + "\hvigor-ohos-plugin\src\tasks\process-profile.js"
$searchString = 'language'
$replaceString = 'codeLanguage'

echo $filePath

# 读取文件内容
$content = Get-Content -Path $filePath -Raw

# 使用正则表达式进行查找和替换
$newContent = [regex]::Replace($content, $searchString, $replaceString)

# 将修改后的内容写回文件
Set-Content -Path $filePath -Value $newContent

Write-Output "替换完成"


$filePath = $hvigor_path + "\hvigor-ohos-plugin\src\tasks\process-profile.js"
$searchString = 'processDependencyHarAbility\(e\)\{'
$replaceString = 'processDependencyHarAbility(e){ if (this.targetService.getSelfArkTSVersion() === common_const_js_1.ArkTSVersionConst.ARKTS1_2) {e.module.codeLanguage = common_const_js_1.LanguageConst.ARKTS1_2};'

echo $filePath

# 读取文件内容
$content = Get-Content -Path $filePath -Raw

# 使用正则表达式进行查找和替换
$newContent = [regex]::Replace($content, $searchString, $replaceString)

# 将修改后的内容写回文件
Set-Content -Path $filePath -Value $newContent

Write-Output "替换完成"